// 渲染店铺列表
function renderStores() {
    const storesList = document.querySelector('.stores-list');
    const storeCount = document.getElementById('store-count');
    
    // 更新店铺数量
    storeCount.textContent = storesData.length;
    
    // 渲染店铺列表
    storesList.innerHTML = storesData.map(store => `
        <div class="store-item" data-id="${store.id}">
            <div class="store-logo">
                <img src="${store.logo}" alt="${store.name}">
            </div>
            <div class="store-info">
                <div class="store-name">
                    ${store.name}
                    <span class="store-type">${store.type}</span>
                </div>
                <div class="store-stats">
                    <span>粉丝数：${store.fans}</span>
                    <span>商品数：${store.products}</span>
                </div>
                <div class="store-date">关注时间：${formatDate(store.date)}</div>
            </div>
            <div class="store-actions">
                <button class="btn-unfollow" onclick="unfollowStore(${store.id})">取消关注</button>
            </div>
        </div>
    `).join('');
}

// 格式化日期
function formatDate(dateString) {
    const date = new Date(dateString);
    return `${date.getFullYear()}年${date.getMonth() + 1}月${date.getDate()}日`;
}

// 取消关注
function unfollowStore(id) {
    if (confirm('确定要取消关注该店铺吗？')) {
        storesData = storesData.filter(store => store.id !== id);
        renderStores();
        showToast('取消关注成功');
    }
}

// 显示提示信息
function showToast(message) {
    const toast = document.createElement('div');
    toast.className = 'toast-message';
    toast.textContent = message;
    
    document.body.appendChild(toast);
    
    setTimeout(() => {
        toast.classList.add('fade-out');
        setTimeout(() => {
            document.body.removeChild(toast);
        }, 300);
    }, 2000);
}

// 页面加载完成后渲染店铺列表
document.addEventListener('DOMContentLoaded', renderStores); 